/*
 * InfoDisplay.java
 *
 * Created on Sekmadienis, 2006, Rugs�jo 17, 11.35
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package keitykla;

import java.util.Hashtable;
import javax.microedition.lcdui.*;


public class InfoDisplay implements CommandListener
{
    private Form frm;
    private StringItem status;
    private StringItem status2;
    private StringItem status3;
    private StringItem status4;
    private StringItem status5;
    private Command cmdCancel;
    private static String focussedCode;

    public static void setFocussedCode(String tt)
    {
	focussedCode = tt;
    }
    private String getFocussedCode()
    {
	return focussedCode;
    }
    public InfoDisplay()
    {
	frm=new Form("Valiutos info");
	status=new StringItem("",getStatusCode());
	frm.append(status);
        status2=new StringItem("",getStatusName());
	frm.append(status2);
        status3=new StringItem("",getStatusRate());
	frm.append(status3);
        status4=new StringItem("",getStatusQuantity());
	frm.append(status4);
        status5=new StringItem("",getStatusDate());
	frm.append(status5);
        cmdCancel=new Command("Atgal",Command.BACK,1);
	frm.addCommand(cmdCancel);
	frm.setCommandListener(this);
    }
    public Displayable getDisplayable()
    {
	return frm;
    }
    
//--------------------------------------------------------------------------
    private String getStatusCode()
    {
        String to_display = null;
        to_display = "Kodas : "+getFocussedCode()+"\n";

        return to_display;
    }
    
//--------------------------------------------------------------------------
    private String getStatusName()
    {
        String to_display = null;
        to_display = "Pavadinimas : "+getCurrency().getName()+"\n";

        return to_display;
    }
    
//--------------------------------------------------------------------------
    private String getStatusRate()
    {
        String to_display = null;
        to_display = "Kursas : "+getCurrency().getRate()+"\n";

        return to_display;
    }
    
//--------------------------------------------------------------------------
    private String getStatusQuantity()
    {
        String to_display = null;
        to_display = "Kiekis : "+getCurrency().getQuantity()+"\n";

        return to_display;
    }    
    
//--------------------------------------------------------------------------
    private String getStatusDate()
    {
        String to_display = null;
        to_display = "Paskutinio atnaujinimo data : "+getCurrency().getDate()+"\n";

        return to_display;
    }    
    
//-----------------get Currency---------------------------------------------
    private Currency getCurrency()
    {
        Currency cur = (Currency)Screens.getSetHashtable().getTable().get(getFocussedCode());
        return cur;
    }       
    
//----------------------------------------------------------------------------    
    
    public void commandAction(Command command, Displayable displayable)
    {
	if(command==cmdCancel)
	{
//            Screens.getFlexCurrencySeletDisplay().refreshList();
            Screens.showFlexCurrencySelect();                
	    return ;
	}
    }
    
}
